/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sntp;

import Settings.BaseSettings;
import java.io.File;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
import Settings.ISettings;

/**
 *
 * @author Tomasz Nowak
 */
@Root
public class SntpClientSettings extends BaseSettings implements ISettings
{
	@Element
	private String[] addresses;

	public SntpClientSettings()
	{
		this.filename = "sntpclientsettings.xml";
	}

	public String[] getAddresses()
	{
		return addresses;
	}

	public void setAddresses( String[] addresses )
	{
		this.addresses = addresses;
	}

	public SntpClientSettings( String[] addresses )
	{
		this();

		this.addresses = addresses;
	}

	@Override
	public void load()
	{
		try
		{
			Serializer serializer = new Persister();
			File source = new File(this.filename);
			this.addresses = serializer.read(SntpClientSettings.class, source).getAddresses();
		}
		catch ( Exception e )
		{
			e.printStackTrace();
		}
	}

	@Override
	public void save()
	{
		try
		{
			Serializer serializer = new Persister();
			File destination = new File(this.filename);
			serializer.write(this, destination);
		}
		catch ( Exception e )
		{
			e.printStackTrace();
		}
	}
}
